<?php
// $Id: Html.php 27 2010-11-16 12:49:54Z mjohnson60@gmail.com $


/**
 * Enter description here ...
 * 
 * @author Mark Phillip Johnson
 * @version 1.0
 * @copyright Copyright (c) 2010, markjohnson
 * @license http://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
 *
 */
class Html extends Object
{
	const DOCTYPE_HTML4_STRICT = 0;
	const DOCTYPE_HTML4_TRANS = 1;
	const DOCTYPE_HTML4_FRAME = 2;
	const DOCTYPE_XHTML_STRICT = 3;
	const DOCTYPE_XHTML_TRANS = 4;
	const DOCTYPE_XHTML_FRAME = 5;
	const DOCTYPE_XHTML11 = 6;

	/**
	 * Enter description here ...
	 * 
	 * @param int $doctype
	 * @return string
	 */
	public static function doctype($doctype = Html::DOCTYPE_XHTML11)
	{
		$output = '';
		switch ($doctype)
		{
			case Html::DOCTYPE_HTML4_STRICT:
				$output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
				break;
			case Html::DOCTYPE_HTML4_TRANS:
				$output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
				break;
			case Html::DOCTYPE_HTML4_FRAME:
				$output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
				break;
			case Html::DOCTYPE_XHTML_STRICT:
				$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
				break;
			case Html::DOCTYPE_XHTML_TRANS:
				$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
				break;
			case Html::DOCTYPE_XHTML_FRAME:
				$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
				break;
			default:
				$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
				break;
		}
		
		return $output;
	}

	/**
	 * Enter description here ...
	 * 
	 * @param string $anchor
	 * @param string $url
	 * @param string $title
	 * @param array $attributes
	 * @return string
	 */
	public static function link($anchor, $url = NULL, $title = '', $attributes = array())
	{
		if (!empty($url))
		{
			$url = valid_url($url);
		}
		
		return '<a ' . (!empty($url) ? 'href="' . check_plain($url) . '" ' : '') . 'title="' . (empty($title) ? '' : check_plain($title)) . '"' . (empty($attributes) ? '' : render_attributes($attributes)) . '>' . check_plain($anchor) . '</a>' . "\n";
	}

	/**
	 * Enter description here ...
	 * 
	 * @param string $src
	 * @param string $title
	 * @param string $alt
	 * @param array $attributes
	 * @return string
	 */
	public static function image($src, $title = '', $alt = '', $attributes = array())
	{
		return '<img src="' . valid_url($src) . '" title="' . check_plain($title) . '" alt="' . check_plain($alt) . '"' . (!empty($attributes) ? render_attributes($attributes) : '') . ' />' . "\n";
	}
}











